package handler;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import windows.Ferestre;

public class keyListener implements KeyListener {
	private Ferestre fereastra;
	private SetFocusComponent setFocusable = new SetFocusComponent();
	public keyListener(Ferestre ferestre) {
		fereastra = ferestre;
	}


	public void keyPressed(KeyEvent arg0) {
		fereastra.getModifyFrame().setKeyCode(arg0.getKeyCode());
		
		System.out.println(arg0.getKeyCode());
		
	}


	public void keyReleased(KeyEvent arg0) {
		if(arg0.getSource()==fereastra.getModifyFrame().getTabelAngajati()){
		fereastra.getModifyFrame().getNewSelectedCell()[0] = fereastra
				.getModifyFrame().getTabelAngajati().getSelectedRow();
		fereastra.getModifyFrame().getNewSelectedCell()[1] = fereastra
				.getModifyFrame().getTabelAngajati().getSelectedColumn();


		}
	}

	
	public void keyTyped(KeyEvent arg0) {
	if(arg0.getSource()==fereastra.getModifyFrame().getTabelAngajati())
		fereastra.getModifyFrame().setTableText(arg0);
	else
		setFocusable.chooseFocusComponent(arg0,fereastra);
	}

}
